home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / RLaB / testmatrix / poldec.r < prev    next >
Text File  |  1994-12-20  |  1KB  |  44 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Polar decomposition.
  4.  
  5. // Syntax:    P = poldec ( A )
  6.  
  7. // Description:
  8.  
  9. //    Poldec computes a matrix U of the same dimension as A, and a
  10. //    Hermitian positive semi-definite matrix H,  such that A =
  11. //    U*H. U has orthonormal columns if m>=n, and orthonormal rows
  12. //    if m<=n. U and H are computed via an SVD of A. U is a nearest
  13. //    unitary matrix to A in both the 2-norm and the Frobenius norm.
  14.  
  15. //    Poldec returns a list with elements `u' and `h'.
  16.  
  17. //      Reference:
  18. //      N.J. Higham, Computing the polar decomposition---with applications,
  19. //      SIAM J. Sci. Stat. Comput., 7(4):1160--1174, 1986.
  20.  
  21. //     (The name `polar' is reserved for a graphics routine.)
  22.  
  23. //    This file is a translation of poldec.m from version 2.0 of
  24. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  25. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  26.  
  27. //-------------------------------------------------------------------//
  28.  
  29. poldec = function ( A )
  30. {
  31.   local (A)
  32.  
  33.   m = A.nr; n = A.nc;
  34.  
  35.   svda = svd(A);    // Economy size.
  36.   svda.sigma = diag(svda.sigma);
  37.  
  38.   U = svda.u*svda.vt;
  39.   H = svda.vt'*svda.sigma*svda.vt;
  40.   H = (H + H')/2;    // Force Hermitian by taking nearest Hermitian matrix.
  41.  
  42.   return << u = U ; h = H >>;
  43. };
  44.